﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SHPBaidu
{
    class Program
    {
        static void Main(string[] args)
        {
            //GetBaiDuRowColomns(110.45148382978, 27.071276162242, 110.45175765523, 27.071480914607, 19);
            //return;
            string shpfile = @"C:\Users\USER\Desktop\SHP\TEST08.shp";
            SHPWriter writer = new SHPWriter();
            writer.Test(shpfile);
        }

        private static double maxResolution = 0.040417623376902342 * Math.Pow(2.0, 5.0);
        private static double[] extents = new double[]
		{
			48.18126729214,
			14.092233098806,
			311.92657635393,
			345.193403802388
		};
        public static void GetBaiDuRowColomns(double minX, double minY, double maxX, double maxY, int zoom)
        {
            // 角度 / 

            int minRow = (int)Math.Floor((minX - extents[0]) / (maxResolution / Math.Pow(2.0, (double)zoom) * 256.0));
            int maxRow = (int)Math.Ceiling((maxX - extents[0]) / (maxResolution / Math.Pow(2.0, (double)zoom) * 256.0));
            int minCol = (int)Math.Floor((minY - extents[1]) / (maxResolution / Math.Pow(2.0, (double)zoom) * 256.0));
            int maxCol = (int)Math.Ceiling((maxY - extents[1]) / (maxResolution / Math.Pow(2.0, (double)zoom) * 256.0));
        }
    }
}
